package com.fsi.server;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Photo {
	// private static final Logger log =
	// Logger.getLogger(Picture.class.getName());

	@PrimaryKey
	private String photoID;

	/**
	 * Used only for direct Pictures.
	 */
	@Persistent
	private String fileName;

	@Persistent
	private String contentType;

	@Persistent
	private Blob content;

	@Persistent
	private String customerID;

	@Persistent
	private boolean isMainImage;

	@Persistent
	private String title;

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public void setCustomerID(String customerID) {
		this.customerID = customerID;
	}

	public void setMainImage(boolean isMainImage) {
		this.isMainImage = isMainImage;
	}

	public boolean isMainImage() {
		return isMainImage;
	}

	public String getCustomerID() {
		return customerID;
	}

	public void setIsMainImage(boolean isMainImage) {
		this.isMainImage = isMainImage;
	}

	public Photo(String photoID, String fileName, String contentType,
			byte[] content, String customerID, boolean isMainImage, String title) {
		super();
		// log.info("constructor for Picture (with byte[]): " + screenName +
		// "; "
		// + fileName + ", " + contentType);
		this.photoID = photoID;
		this.fileName = fileName;
		this.contentType = contentType;
		this.customerID = customerID;
		this.isMainImage = isMainImage;
		System.out.println("customer id = " + customerID);
		this.content = new Blob(content);
		this.title = title;
	}

	public String getPhotoID() {
		return photoID;
	}

	public void setPhotoID(String photoID) {
		this.photoID = photoID;
	}

	/**
	 * @return the fileName
	 */
	public String getFileName() {
		return fileName;
	}

	/**
	 * @return the contentType
	 */
	public String getContentType() {
		return contentType;
	}

	/**
	 * @param contentType
	 *            the contentType to set
	 */
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	/**
	 * @return the content
	 */
	public Blob getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(Blob content) {
		this.content = content;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

}
// public Photo(String screenName, String fileName, String contentType,
// String content, String customerID, boolean isMainImage) {
// super();
// // log.info("constructor for Picture: " + screenName + "; " + fileName
// // + ", " + contentType);
// this.screenName = screenName;
// this.fileName = fileName;
// this.contentType = contentType;
// this.customerID = customerID;
// this.isMainImage = isMainImage;
// try {
// this.content = new Blob(content.getBytes("UTF-8"));
// } catch (UnsupportedEncodingException e) {
// // log.info("encoding error during creation of the picture blob");
// // e.printStackTrace();
// }
// }
